package com.trg.flex
{
	import com.trg.flex.dp.DataProvider;
	
	import flash.utils.Dictionary;
	
	public class DataProviderUpdater
	{
		private var classes:Dictionary = new Dictionary();
		
		public function register(klass:Class, dataProvider:DataProvider):void {
			if (!classes[klass]) {
				classes[klass] = new Dictionary(true);
			}
			classes[klass][dataProvider] = true;
		}
		
		public function unregister(dataProvider:DataProvider):void {
			for each (var dict:Dictionary in classes) {
				delete dict[dataProvider];
			}
		}
		
		public function refresh(klass:Class):void {
			var dict:Dictionary = classes[klass];
			if (dict) {
				for (var dp:DataProvider in dict) {
					dp.refresh();
				}
			}
		}
	}
}